#include <pspsdk.h>
#include "libmp3.h"

/*
 * Imports from library: Kernel_Library
 */
extern int sceKernelCpuSuspendIntr (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7);
extern void sceKernelCpuResumeIntr (int arg1);

/*
 * Imports from library: sceAudiocodec
 */
extern int sceAudiocodecReleaseEDRAM (int arg1);
extern int sceAudiocodecGetEDRAM (int arg1, int arg2);
extern int sceAudiocodec_59176A0F (int arg1, int arg2, int arg3);
extern int sceAudiocodecInit (int arg1, int arg2);
extern int sceAudiocodecDecode (int arg1, int arg2);
extern int sceAudiocodecGetInfo (int arg1, int arg2);
extern int sceAudiocodecCheckNeedMem (int arg1, int arg2);

/*
 * Imports from library: SysMemUserForUser
 */
extern int sceKernelGetCompiledSdkVersion ();

/**
 * Subroutine at address 0x00000000
 */
int sub_00000 ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[1] = ra;
  var3 = sceAudiocodecCheckNeedMem (0x00001600, 0x00001002);
  var4 = var3;
  if (!(var3 < 0))
  {
    var5 = *((int *) 0x00001610);
    var6 = ((var5 + 0x0000003F) & 0xFFFFFFC0) | (0x00000000 & 0x0000003F);
    *((int *) 0x000015D4) = var6;
    *((int *) 0x00001610) = (var6 << 0x00000001);
    var9 = sceAudiocodecGetEDRAM (0x00001600, 0x00001002);
    var4 = var9;
    if (!(var9 < 0))
    {
      var10 = *((int *) 0x0000160C);
      var4 = 0x00000000;
      *((int *) 0x000015D0) = var10;
    }
  }
  ra = ((int *) sp)[1];
  var11 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return var4;
}

/**
 * Subroutine at address 0x0000007C
 */
void sub_0007C (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[2] = ra;
  var1 = ((arg1 << 0x00000001) + arg1) << 0x00000006;
  ((int *) sp)[1] = s1;
  var2 = var1 + 0x00001680;
  var3 = ((int *) var2)[8];
  var4 = ((int *) var2)[7];
  var5 = ((int *) var2)[6];
  var6 = ((int *) (var1 + 0x00001600))[6];
  if ((((((var5 + (var4 << 0x00000001)) - var6) + 0x000005C0) < 0x000005A1)) != 0x00000000)
  {
    sub_0014C (arg1);
    var4 = ((int *) var2)[7];
  }
  var7 = ((int *) var2)[10];
  ra = ((int *) sp)[2];
  if (!(((var4 < var7)) != 0x00000000))
  {
    var8 = ((int *) var2)[9];
    if (var8 == ((var5 + (var4 * (var3 + 0x00000001))) + 0x000005C0))
    {
      var11 = ((int *) var2)[8];
      var12 = ((int *) var2)[6];
      var13 = var11 ^ 0x00000001;
      ((int *) var2)[8] = var13;
      ((int *) var2)[9] = ((var12 + (var4 * var13)) + 0x000005C0);
    }
    ra = ((int *) sp)[2];
  }
  var9 = ((int *) sp)[1];
  var10 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x0000014C
 */
void sub_0014C (int arg1)
{
  var1 = ((arg1 << 0x00000001) + arg1) << 0x00000006;
  var2 = var1 + 0x00001680;
  var3 = ((int *) var2)[7];
  var4 = ((int *) var2)[6];
  var5 = var1 + 0x00001600;
  var6 = ((int *) var5)[6];
  var7 = (var4 + (var3 << 0x00000001)) - var6;
  var8 = var4 - var7;
  var9 = var7 + 0x000005C0;
  var10 = var8;
  if (((var10 >> 30) & 0x00000001) != 0x00000000)
  {
    var11 = var10 + var9;

    label12:
    while (1) {
      var10 = var10 + 0x00000001;
      var29 = ((unsigned char *) var6)[0];
      var6 = var6 + 0x00000001;
      ((char *) var10)[-1] = var29;
      if (var10 != var11)
        continue;
      break;
    }
  }
  else
  {
    var11 = var10 + var9;
    if (((var9 < 0x00000080)) != 0x00000000)
    {

    label11:
      if (!(var10 == var11))
        goto label12;
    }
    else
    {
      if (((var10 ^ var6) & 0x00000003) != 0x00000000)
        goto label12;
      while (1) {
        var12 = ((unsigned char *) var6)[0];
        if ((((var10 + 0x0000003F) & 0xFFFFFFC0) | (0x00000000 & 0x0000003F)) == var10)
          break;
        var10 = var10 + 0x00000001;
        var6 = var6 + 0x00000001;
        ((char *) var10)[-1] = var12;
        continue;
      }
      while (1) {
        __asm__ ("cache      0x18, 0($v1);"
          : 
          : "=r"(var10));
        var13 = ((int *) var6)[0];
        ((int *) var10)[0] = var13;
        var14 = ((int *) var6)[1];
        ((int *) var10)[1] = var14;
        var15 = ((int *) var6)[2];
        ((int *) var10)[2] = var15;
        var16 = ((int *) var6)[3];
        ((int *) var10)[3] = var16;
        var17 = ((int *) var6)[4];
        ((int *) var10)[4] = var17;
        var18 = ((int *) var6)[5];
        ((int *) var10)[5] = var18;
        var19 = ((int *) var6)[6];
        ((int *) var10)[6] = var19;
        var20 = ((int *) var6)[7];
        ((int *) var10)[7] = var20;
        var21 = ((int *) var6)[8];
        ((int *) var10)[8] = var21;
        var22 = ((int *) var6)[9];
        ((int *) var10)[9] = var22;
        var23 = ((int *) var6)[10];
        ((int *) var10)[10] = var23;
        var24 = ((int *) var6)[11];
        ((int *) var10)[11] = var24;
        var25 = ((int *) var6)[12];
        ((int *) var10)[12] = var25;
        var26 = ((int *) var6)[13];
        ((int *) var10)[13] = var26;
        var27 = ((int *) var6)[14];
        ((int *) var10)[14] = var27;
        var10 = var10 + 0x00000040;
        var28 = ((int *) var6)[15];
        var6 = var6 + 0x00000040;
        ((int *) var10)[1073741823] = var28;
        if (var10 != ((var11 & 0xFFFFFFC0) | (0x00000000 & 0x0000003F)))
          continue;
        break;
      }
      goto label11;
    }
  }
  ((int *) var5)[6] = var8;
  return;
}

/**
 * Subroutine at address 0x00000290
 */
int sceMp3TermResource ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = ra;
  ((int *) sp)[0] = s0;
  var1 = 0x00000000;
  while (1) {
    var4 = sceMp3ReleaseMp3Handle (var1);
    var1 = var1 + 0x00000001;
    if (var4 < 0)
      break;
    if (((var1 < 0x00000002)) != 0x00000000)
      continue;
    var7 = mp3InitRessource (0x00000000);
    var4 = MIN (var7, 0x00000000);
    goto label10;
  }

label10:
  ra = ((int *) sp)[1];
  var8 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return var4;
}

/**
 * Subroutine at address 0x000002DC
 */
void sceMp3ReserveMp3Handle (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[1] = s1;
  var1 = 0xFFFFFFFF;
  ((int *) sp)[0] = s0;
  var2 = arg1;
  ((int *) sp)[2] = ra;
  if (arg1 == 0x00000000)
  {

  label28:

  label29:
    var5 = 0x80671002;
  }
  else
  {
    var3 = ((int *) arg1)[4];
    if (var3 == 0x00000000)
      goto label29;
    var4 = ((int *) arg1)[6];
    if (!(var4 != 0x00000000))
      goto label28;
    var8 = ((int *) arg1)[1];
    if (var8 < 0)
    {

    label27:
      var5 = 0x80671003;
    }
    else
    {
      var9 = ((int *) arg1)[3];
      var10 = (var8 < var9);
      if (var10 != 0x00000000)
      {
        var14 = ((int *) var2)[5];

      label13:
        var15 = (var14 < 0x00002000);
        if (var15 != 0x00000000)
          goto label27;
        var16 = ((int *) var2)[7];
        if (((var16 < 0x00002400)) != 0x00000000)
        {
          var5 = 0x80671003;
        }
        else
        {
          var19 = sceKernelCpuSuspendIntr (var13, var10, var12, var11, var15, var14, 0x80671003);
          var20 = 0x00001600;
          var21 = 0x00000000;
          var22 = 0x00001680;
          while (1) {
            var23 = ((int *) var22)[0];
            var22 = var22 + 0x000000C0;
            if (var23 == 0x00000000)
            {
              var1 = var21;
              ((int *) var20)[32] = 0x00000001;
            }
            else
            {
              var21 = var21 + 0x00000001;
              var20 = var20 + 0x000000C0;
              if (((var21 < 0x00000002)) != 0x00000000)
                continue;
              break;
            }
          }
          sceKernelCpuResumeIntr (var19);
          var5 = 0x80671201;
          if (!(var1 < 0))
          {
            var26 = ((int *) var2)[0];
            var27 = ((int *) var2)[2];
            var28 = ((var1 << 0x00000001) + var1) << 0x00000006;
            var29 = var28 + 0x00001680;
            ((int *) var29)[1] = 0xFFFFFFFF;
            ((int *) var29)[3] = var26;
            var30 = var28 + 0x00001600;
            ((int *) var29)[4] = var27;
            var5 = var1;
            ((int *) var29)[5] = var26;
            ((int *) var29)[2] = 0x00000000;
            var31 = ((int *) var2)[4];
            var32 = ((int *) var2)[5];
            var33 = *((int *) 0x000015C0);
            var34 = var31 + 0x000005C0;
            var35 = var32 + 0xFFFFFA40;
            ((int *) var29)[6] = var31;
            ((int *) var29)[9] = var34;
            var36 = ((int *) var2)[6];
            ((int *) var29)[7] = ((var35 + (var35 >> 0x0000001F)) >> 0x00000001);
            ((int *) var29)[8] = ((0x00000000 < var33));
            ((int *) var29)[11] = (var27 - var26);
            ((int *) var29)[10] = 0x00000000;
            ((int *) var29)[12] = var36;
            var37 = ((int *) var2)[7];
            ((int *) var30)[6] = var34;
            var38 = ((int *) var29)[12];
            ((int *) var29)[14] = 0x00000000;
            ((int *) var29)[13] = ((var37 + (var37 >> 0x0000001F)) >> 0x00000001);
            ((int *) var29)[15] = 0x00000000;
            ((int *) var30)[8] = var38;
            ((int *) var30)[10] = 0x000005A1;
            ((int *) var29)[0] = 0x00000002;
          }
        }
      }
      else
      {
        if (var9 == var8)
        {
          var11 = ((int *) var2)[2];
          var12 = ((int *) var2)[0];
          var13 = (var12 < var11);
          if (var13 == 0x00000000)
            goto label27;
          var14 = ((int *) var2)[5];
          goto label13;
        }
        else
        {
          goto label27;
        }
      }
    }
  }
  ra = ((int *) sp)[2];
  var6 = ((int *) sp)[1];
  var7 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x000004B8
 */
int sceMp3ReleaseMp3Handle (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  var1 = ((arg1 << 0x00000001) + arg1) << 0x00000006;
  var2 = (arg1 < 0x00000002);
  ((int *) sp)[0] = s0;
  var3 = var1 + 0x00001680;
  var4 = 0x80671001;
  ((int *) sp)[1] = ra;
  if (!(var2 == 0x00000000))
  {
    var7 = sceKernelCpuSuspendIntr (arg1, 0x80671001, var2, 0x80670000, var1, 0x00000000, arg7);
    var8 = ((int *) var3)[0];
    if (!(var8 <= 0))
    {
      ((int *) var3)[0] = 0x00000000;
    }
    sceKernelCpuResumeIntr (var7);
    var4 = 0x00000000;
  }
  ra = ((int *) sp)[1];
  var11 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return var4;
}

/**
 * Subroutine at address 0x00000524
 */
void sceMp3Init (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  var1 = arg1;
  var2 = ((arg1 << 0x00000001) + var1) << 0x00000006;
  ((int *) sp)[2] = s2;
  var3 = 0x80671001;
  var4 = var2 + 0x00001680;
  ((int *) sp)[3] = ra;
  ((int *) sp)[1] = s1;
  if (!(((var1 < 0x00000002)) == 0x00000000))
  {
    var5 = ((int *) var4)[0];
    var6 = var2 + 0x00001600;
    var3 = 0x80671102;
    if (!(((var5 < 0x00000002)) != 0x00000000))
    {
      var9 = sceAudiocodecInit (var6, 0x00001002);
      if (!(var9 < 0))
      {
        var12 = sceAudiocodecGetInfo (var6, 0x00001002);
        var9 = MIN (var12, 0x00000000);
      }
      var3 = var9;
      if (!(var9 < 0))
      {
        var15 = mp3Init (var1);
        var3 = var15;
        if (!(var15 < 0))
        {
          ((int *) var4)[0] = 0x00000003;
          var3 = 0x00000000;
        }
      }
    }
  }
  ra = ((int *) sp)[3];
  var16 = ((int *) sp)[2];
  var17 = ((int *) sp)[1];
  var18 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x000005F0
 */
void sceMp3Decode (int arg1, int arg2)
{
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[1] = s1;
  var1 = arg1;
  var2 = ((arg1 << 0x00000001) + arg1) << 0x00000006;
  ((int *) sp)[2] = s2;
  var3 = var2 + 0x00001600;
  var4 = 0x80671001;
  ((int *) sp)[0] = s0;
  var5 = var2 + 0x00001680;
  ((int *) sp)[4] = ra;
  ((int *) sp)[3] = s3;
  if (!(((var1 < 0x00000002)) == 0x00000000))
  {
    var6 = ((int *) var5)[0];
    var4 = 0x80671103;
    if (!(((var6 < 0x00000003)) != 0x00000000))
    {
      if (arg2 == 0x00000000)
      {
        var8 = ((int *) var5)[2];
      }
      else
      {
        var7 = ((int *) var3)[8];
        ((int *) arg2)[0] = var7;
        var8 = ((int *) var5)[2];
      }
      if (var8 == 0x00000000)
      {
        var23 = ((int *) var5)[5];
        var24 = ((int *) var5)[4];
        if (var23 == var24)
        {
          var58 = ((int *) var5)[11];
          if (var58 > 0)
          {

          label14:
            var38 = sceAudiocodecDecode (var3, 0x00001002);
            if (var38 < 0)
            {
              var55 = mp3Decode (var1);
              var4 = var38;
              if (!(var55 == 0x00000000))
              {
                sub_0118C (var1);
                var4 = 0x80671402;
              }
            }
            else
            {
              var39 = ((int *) var3)[9];
              var4 = 0x80671401;
              if (!(var39 == 0x00000000))
              {
                var40 = ((int *) var3)[7];
                var41 = ((int *) var5)[10];
                var42 = ((int *) var3)[6];
                var43 = ((int *) var5)[11];
                ((int *) var5)[10] = (var41 - var40);
                var44 = ((int *) var3)[7];
                var45 = ((int *) var5)[14];
                var46 = ((int *) var5)[13];
                var47 = var45 ^ 0x00000001;
                ((int *) var3)[6] = (var42 + var40);
                ((int *) var5)[11] = (var43 - var44);
                var48 = ((int *) var5)[15];
                var49 = ((int *) var3)[9];
                var50 = ((int *) var5)[12];
                ((int *) var3)[8] = (var50 + (var46 * var47));
                ((int *) var5)[15] = (var48 + var49);
                ((int *) var5)[14] = var47;
                sub_0118C (var1);
                var4 = ((int *) var3)[9];
              }
            }
          }
          else
          {
            var26 = ((int *) var3)[8];

          label28:
            var27 = 0x00000000;
            var28 = ((int *) var5)[13];
            var29 = var26 + var28;
            if (((var26 >> 30) & 0x00000001) != 0x00000000)
            {

              label34:
              while (1) {
                if (var26 == var29)
                  break;
                var26 = var26 + 0x00000001;
                ((char *) var26)[-1] = var27;
                continue;
              }
            }
            else
            {
              var30 = (0x00000000 & 0xFFFF00FF) | (0x00000000 & 0x000000FF);
              var27 = (var30 & 0x0000FFFF) | (var30 & 0x0000FFFF);
              while (1) {
                if (var26 == var29)
                  break;
                ((char *) var26)[0] = var27;
                if ((var26 & 0x0000003F) == 0x00000000)
                {
                  var31 = (var29 & 0xFFFFFFC0) | (0x00000000 & 0x0000003F);
                  if (!(var26 == var31))
                  {
                    while (1) {
                      __asm__ ("cache      0x18, 0($t8);"
                        : 
                        : "=r"(var26));
                      ((int *) var26)[0] = var27;
                      ((int *) var26)[1] = var27;
                      ((int *) var26)[2] = var27;
                      ((int *) var26)[3] = var27;
                      ((int *) var26)[4] = var27;
                      ((int *) var26)[5] = var27;
                      ((int *) var26)[6] = var27;
                      ((int *) var26)[7] = var27;
                      ((int *) var26)[8] = var27;
                      ((int *) var26)[9] = var27;
                      ((int *) var26)[10] = var27;
                      ((int *) var26)[11] = var27;
                      ((int *) var26)[12] = var27;
                      ((int *) var26)[13] = var27;
                      ((int *) var26)[14] = var27;
                      var26 = var26 + 0x00000040;
                      ((int *) var26)[1073741823] = var27;
                      if (var26 != var31)
                        continue;
                      break;
                    }
                  }
                  goto label34;
                }
                else
                {
                  var26 = var26 + 0x00000001;
                  continue;
                }
              }
            }
            var32 = ((int *) var5)[14];
            var33 = ((int *) var5)[13];
            var34 = ((int *) var5)[12];
            var35 = var32 ^ 0x00000001;
            ((int *) var5)[14] = var35;
            var4 = var33;
            ((int *) var3)[8] = (var34 + (var33 * var35));
          }
        }
        else
        {
          var25 = ((int *) var5)[10];
          if (((var25 < 0x000005A1)) == 0x00000000)
            goto label14;
          var26 = ((int *) var3)[8];
          goto label28;
        }
      }
      else
      {
        var9 = ((int *) var3)[8];
        var10 = 0x00000000;
        var11 = ((int *) var5)[13];
        var12 = var9 + var11;
        if (((var9 >> 30) & 0x00000001) != 0x00000000)
        {

          label45:
          while (1) {
            if (var9 == var12)
              break;
            var9 = var9 + 0x00000001;
            ((char *) var9)[-1] = var10;
            continue;
          }
        }
        else
        {
          var13 = (0x00000000 & 0xFFFF00FF) | (0x00000000 & 0x000000FF);
          var10 = (var13 & 0x0000FFFF) | (var13 & 0x0000FFFF);
          while (1) {
            if (var9 == var12)
              break;
            ((char *) var9)[0] = var10;
            if ((var9 & 0x0000003F) == 0x00000000)
            {
              var14 = (var12 & 0xFFFFFFC0) | (0x00000000 & 0x0000003F);
              if (!(var9 == var14))
              {
                while (1) {
                  __asm__ ("cache      0x18, 0($t1);"
                    : 
                    : "=r"(var9));
                  ((int *) var9)[0] = var10;
                  ((int *) var9)[1] = var10;
                  ((int *) var9)[2] = var10;
                  ((int *) var9)[3] = var10;
                  ((int *) var9)[4] = var10;
                  ((int *) var9)[5] = var10;
                  ((int *) var9)[6] = var10;
                  ((int *) var9)[7] = var10;
                  ((int *) var9)[8] = var10;
                  ((int *) var9)[9] = var10;
                  ((int *) var9)[10] = var10;
                  ((int *) var9)[11] = var10;
                  ((int *) var9)[12] = var10;
                  ((int *) var9)[13] = var10;
                  ((int *) var9)[14] = var10;
                  var9 = var9 + 0x00000040;
                  ((int *) var9)[1073741823] = var10;
                  if (var9 != var14)
                    continue;
                  break;
                }
              }
              goto label45;
            }
            else
            {
              var9 = var9 + 0x00000001;
              continue;
            }
          }
        }
        var15 = ((int *) var5)[14];
        var16 = ((int *) var5)[13];
        var17 = ((int *) var5)[12];
        var18 = var15 ^ 0x00000001;
        var4 = 0x00000000;
        ((int *) var5)[14] = var18;
        ((int *) var3)[8] = (var17 + (var16 * var18));
      }
    }
  }
  ra = ((int *) sp)[4];
  var19 = ((int *) sp)[3];
  var20 = ((int *) sp)[2];
  var21 = ((int *) sp)[1];
  var22 = ((int *) sp)[0];
  sp = sp + 0x00000020;
  return;
}

/**
 * Subroutine at address 0x00000908
 */
void sceMp3GetInfoToAddStreamData (int arg1, int arg2, int arg3, int arg4)
{
  var1 = (((arg1 << 0x00000001) + arg1) << 0x00000006) + 0x00001680;
  var2 = ((int *) var1)[8];
  var3 = ((int *) var1)[7];
  var4 = ((int *) var1)[6];
  var5 = (var4 + (var3 * (var2 + 0x00000001))) + 0x000005C0;
  var6 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var7 = ((int *) var1)[0];
    var6 = 0x80671102;
    if (!(((var7 < 0x00000002)) != 0x00000000))
    {
      var8 = ((int *) var1)[5];
      var9 = ((int *) var1)[4];
      if (var8 == var9)
      {

      label6:
        if (arg4 != 0x00000000)
        {
          ((int *) arg4)[0] = 0x00000000;
        }
        if (arg2 != 0x00000000)
        {
          ((int *) arg2)[0] = 0x00000000;
        }
        if (arg3 != 0x00000000)
        {
          ((int *) arg3)[0] = 0x00000000;

        label19:
          var6 = 0x00000000;
        }
        else
        {
          var6 = 0x00000000;
        }
      }
      else
      {
        var10 = ((int *) var1)[9];
        if (((var10 < var5)) == 0x00000000)
          goto label6;
        if (arg4 != 0x00000000)
        {
          ((int *) arg4)[0] = var8;
        }
        if (!(arg2 == 0x00000000))
        {
          var11 = ((int *) var1)[9];
          ((int *) arg2)[0] = var11;
        }
        var6 = 0x00000000;
        if (!(arg3 == 0x00000000))
        {
          var12 = ((int *) var1)[9];
          ((int *) arg3)[0] = (var5 - var12);
          goto label19;
        }
      }
    }
  }
  return;
}

/**
 * Subroutine at address 0x000009DC
 */
void sceMp3NotifyAddStreamData (int arg1, int arg2)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  var1 = (((arg1 << 0x00000001) + arg1) << 0x00000006) + 0x00001680;
  var2 = ((int *) var1)[8];
  var3 = ((int *) var1)[7];
  var4 = ((int *) var1)[6];
  var5 = ((int *) var1)[4];
  var6 = ((int *) var1)[9];
  var7 = ((int *) var1)[5];
  var8 = var5 - var7;
  var9 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var10 = ((int *) var1)[0];
    var9 = 0x80671102;
    if (!(((var10 < 0x00000002)) != 0x00000000))
    {
      var9 = 0x80671003;
      if (!(((arg2 >> 0x0000001F) & (((((var4 + (var3 * (var2 + 0x00000001))) + 0x000005C0) - var6) < arg2))) != 0x00000000))
      {
        if (((var8 < arg2)) == 0x00000000)
        {
          var15 = ((int *) var1)[10];
          ((int *) var1)[5] = (var7 + arg2);
          var12 = var15 + arg2;
          ((int *) var1)[9] = (var6 + arg2);
        }
        else
        {
          var11 = ((int *) var1)[10];
          ((int *) var1)[5] = var5;
          var12 = var11 + var8;
          ((int *) var1)[9] = (var6 + var8);
        }
        ((int *) var1)[10] = var12;
        sub_0007C (arg1);
        var9 = 0x00000000;
      }
    }
  }
  ra = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00000AC8
 */
void sceMp3ResetPlayPosition (int arg1)
{
  var1 = ((arg1 << 0x00000001) + arg1) << 0x00000006;
  var2 = var1 + 0x00001680;
  var3 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var4 = ((int *) var2)[0];
    var3 = 0x80671103;
    if (!(((var4 < 0x00000003)) != 0x00000000))
    {
      var5 = ((int *) var2)[6];
      var6 = *((int *) 0x000015C0);
      ((int *) (var1 + 0x00001600))[6] = (var5 + 0x000005C0);
      var3 = 0x00000000;
      var7 = ((int *) var2)[3];
      var8 = ((int *) var2)[4];
      var9 = ((int *) var2)[6];
      ((int *) var2)[2] = 0x00000000;
      ((int *) var2)[10] = 0x00000000;
      ((int *) var2)[8] = ((0x00000000 < var6));
      ((int *) var2)[9] = (var9 + 0x000005C0);
      ((int *) var2)[11] = (var8 - var7);
      ((int *) var2)[5] = var7;
      ((int *) var2)[15] = 0x00000000;
    }
  }
  return;
}

/**
 * Subroutine at address 0x00000B60
 */
void sceMp3SetLoopNum (int arg1, int arg2)
{
  var1 = (((arg1 << 0x00000001) + arg1) << 0x00000006) + 0x00001680;
  var2 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var3 = ((int *) var1)[0];
    var2 = 0x80671102;
    if (!(((var3 < 0x00000002)) != 0x00000000))
    {
      if (arg2 < 0)
      {
        arg2 = 0xFFFFFFFF;
      }
      ((int *) var1)[1] = arg2;
      var2 = 0x00000000;
    }
  }
  return;
}

/**
 * Subroutine at address 0x00000BB4
 */
void sceMp3GetMaxOutputSample (int arg1)
{
  var1 = ((arg1 << 0x00000001) + arg1) << 0x00000006;
  sp = sp + 0xFFFFFFE0;
  ((int *) sp)[4] = ra;
  var2 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var3 = ((int *) (var1 + 0x00001680))[0];
    var4 = sp;
    var2 = 0x80671103;
    if (!(((var3 < 0x00000003)) != 0x00000000))
    {
      var7 = sceAudiocodec_59176A0F ((var1 + 0x00001600), 0x00001002, var4);
      var2 = var7;
      if (!(var7 < 0))
      {
        var8 = ((int *) sp)[0];
        var2 = var8 >> 0x00000002;
      }
    }
  }
  ra = ((int *) sp)[4];
  sp = sp + 0x00000020;
  return;
}

/**
 * Subroutine at address 0x00000C34
 */
void sceMp3GetSamplingRate (int arg1)
{
  var1 = ((arg1 << 0x00000001) + arg1) << 0x00000006;
  var2 = var1 + 0x00001600;
  var3 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var4 = ((int *) (var1 + 0x00001680))[0];
    var3 = 0x80671103;
    if (!(((var4 < 0x00000003)) != 0x00000000))
    {
      var5 = ((int *) var2)[14];
      var6 = ((int *) var2)[18];
      var3 = ((int *) (((((var5 << 0x00000001) + var5) + var6) << 0x00000002) + 0x0000149C))[0];
    }
  }
  return;
}

/**
 * Subroutine at address 0x00000CA8
 */
void sceMp3GetBitRate (int arg1)
{
  var1 = ((arg1 << 0x00000001) + arg1) << 0x00000006;
  var2 = var1 + 0x00001600;
  var3 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var4 = ((int *) (var1 + 0x00001680))[0];
    var3 = 0x80671103;
    if (!(((var4 < 0x00000003)) != 0x00000000))
    {
      var5 = ((int *) var2)[14];
      var6 = ((int *) var2)[17];
      var3 = ((int *) ((((var5 << 0x00000004) + var6) << 0x00000002) + 0x000014C0))[0];
    }
  }
  return;
}

/**
 * Subroutine at address 0x00000D18
 */
void sceMp3GetMp3ChannelNum (int arg1)
{
  var1 = ((arg1 << 0x00000001) + arg1) << 0x00000006;
  var2 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var3 = ((int *) (var1 + 0x00001680))[0];
    var2 = 0x80671103;
    if (!(((var3 < 0x00000003)) != 0x00000000))
    {
      var4 = ((int *) (var1 + 0x00001600))[21];
      var2 = ((var4 ^ 0x00000003)) ? 0x00000002 : 0x00000001;
    }
  }
  return;
}

/**
 * Subroutine at address 0x00000D78
 */
void sceMp3StartEntry (int arg1, int arg2)
{
  if ((((0x00000000 < arg2)) & (((arg1 ^ 0x00000004) < 0x00000001))) == 0x00000000)
  {
    var1 = 0x00000001;
  }
  else
  {
    var1 = ((int *) arg2)[0];
  }
  *((int *) 0x000015C0) = var1;
  return;
}

/**
 * Subroutine at address 0x00000DA4
 */
void sceMp3EndEntry ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  var3 = sceMp3TermResource ();
  ra = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00000DC8
 */
void sceMp3InitResource ()
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  var3 = mp3InitRessource (0x00000002);
  ra = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return;
}

/**
 * Subroutine at address 0x00000DEC
 */
void sceMp3CheckStreamDataNeeded (int arg1)
{
  var1 = (((arg1 << 0x00000001) + arg1) << 0x00000006) + 0x00001680;
  var2 = ((int *) var1)[8];
  var3 = ((int *) var1)[7];
  var4 = ((int *) var1)[6];
  var5 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var6 = ((int *) var1)[0];
    var5 = 0x80671102;
    if (!(((var6 < 0x00000002)) != 0x00000000))
    {
      var7 = ((int *) var1)[5];
      var8 = ((int *) var1)[4];
      var5 = 0x00000000;
      if (!(var7 == var8))
      {
        var9 = ((int *) var1)[9];
        var5 = ((var9 < ((var4 + (var3 * (var2 + 0x00000001))) + 0x000005C0)));
      }
    }
  }
  return;
}

/**
 * Subroutine at address 0x00000E70
 */
void sceMp3GetSumDecodedSample (int arg1)
{
  var1 = (((arg1 << 0x00000001) + arg1) << 0x00000006) + 0x00001680;
  var2 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var3 = ((int *) var1)[0];
    var2 = 0x80671102;
    if (!(((var3 < 0x00000002)) != 0x00000000))
    {
      var4 = ((int *) var1)[15];
      var2 = var4 >> 0x00000002;
    }
  }
  return;
}

/**
 * Subroutine at address 0x00000EBC
 */
void sceMp3GetLoopNum (int arg1)
{
  var1 = (((arg1 << 0x00000001) + arg1) << 0x00000006) + 0x00001680;
  var2 = 0x80671001;
  if (!(((arg1 < 0x00000002)) == 0x00000000))
  {
    var3 = ((int *) var1)[0];
    var2 = 0x80671102;
    if (!(((var3 < 0x00000002)) != 0x00000000))
    {
      var2 = ((int *) var1)[1];
    }
  }
  return;
}

/**
 * Subroutine at address 0x00000F04
 */
int mp3InitRessource (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  var1 = arg1;
  var2 = (arg1 < 0x00000003);
  ((int *) sp)[2] = ra;
  var3 = 0x80671001;
  ((int *) sp)[1] = s1;
  if (var2 == 0x00000000)
  {

  label33:
    ra = ((int *) sp)[2];
  }
  else
  {
    var6 = sceKernelCpuSuspendIntr (var2, arg2, arg3, arg4, arg5, arg6, arg7);
    var7 = var6;
    var8 = 0x00001680;
    var9 = 0x00000000;
    var10 = *((int *) 0x00001680);
    while (1) {
      var9 = var9 + 0x00000001;
      var8 = var8 + 0x000000C0;
      if (var10 > 0)
        break;
      if (((var9 < 0x00000002)) != 0x00000000)
      {
        var10 = ((int *) var8)[0];
        continue;
      }
      else
      {
        var11 = 0x00001680;
        var12 = 0x00000001;
        while (1) {
          var12 = var12 + 0xFFFFFFFF;
          ((int *) var11)[0] = 0xFFFFFFFF;
          var11 = var11 + 0x000000C0;
          if (var12 >= 0)
            continue;
          break;
        }
        sceKernelCpuResumeIntr (var7);
        if (var1 != 0x00000000)
        {
          var21 = *((int *) 0x000015D0);
          if (var21 == 0x00000000)
          {
            var28 = sub_00000 ();
            var3 = var28;
            if (var28 >= 0)
            {

            label23:
              if (var1 <= 0)
              {

              label32:
                var3 = 0x00000000;
              }
              else
              {
                var22 = *((int *) 0x000015D4);
                var23 = *((int *) 0x000015D0);
                var24 = 0x00001600;
                var25 = var1;
                while (1) {
                  var25 = var25 + 0xFFFFFFFF;
                  ((int *) var24)[3] = var23;
                  var23 = var23 + var22;
                  ((int *) var24)[5] = 0x00000001;
                  ((int *) var24)[32] = 0x00000000;
                  var24 = var24 + 0x000000C0;
                  if (var25 != 0x00000000)
                    continue;
                  break;
                }
                var3 = 0x00000000;
              }
              goto label33;
            }
            else
            {
              ra = ((int *) sp)[2];
            }
          }
          else
          goto label23;
        }
        else
        {
          var15 = *((int *) 0x000015D0);
          if (!(var15 != 0x00000000))
            goto label32;
          *((int *) 0x000015D0) = 0x00000000;
          *((int *) 0x000015D4) = 0x00000000;
          var20 = sceAudiocodecReleaseEDRAM (0x00001600);
          var3 = var20;
          if (var20 >= 0)
            goto label32;
          ra = ((int *) sp)[2];
        }
      }
      goto label34;
    }
    sceKernelCpuResumeIntr (var7);
    var3 = 0x80671101;
    goto label33;
  }

label34:
  var16 = ((int *) sp)[1];
  var17 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return var3;
}

/**
 * Subroutine at address 0x0000105C
 */
int mp3Init (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = s0;
  ((int *) sp)[1] = ra;
  var1 = (((arg1 << 0x00000001) + arg1) << 0x00000006) + 0x00001600;
  var2 = ((int *) var1)[14];
  var3 = 0x80671301;
  if (var2 != 0x00000001)
  {

  label12:
    ra = ((int *) sp)[1];
  }
  else
  {
    var4 = ((int *) var1)[15];
    if (!(var4 == 0x00000003))
      goto label12;
    var8 = sceKernelGetCompiledSdkVersion ();
    var3 = 0x80671302;
    if (((0x030904FF < var8)) != 0x00000000)
    {
      var10 = ((int *) var1)[18];
      if (((var10 < 0x00000003)) != 0x00000000)
      {
        var3 = 0x00000000;
        goto label12;
      }
      else
      {
        ra = ((int *) sp)[1];
      }
    }
    else
    {
      var9 = ((int *) var1)[18];
      var3 = 0x80671302;
      if (!(var9 != 0x00000000))
      {
        var3 = 0x00000000;
      }
      goto label12;
    }
  }
  var5 = ((int *) sp)[0];
  sp = sp + 0x00000010;
  return var3;
}

/**
 * Subroutine at address 0x00001108
 */
int mp3Decode (int arg1)
{
  var1 = ((arg1 << 0x00000001) + arg1) << 0x00000006;
  var2 = var1 + 0x00001680;
  var3 = var1 + 0x00001600;
  var4 = 0x00000000;
  var5 = ((int *) var3)[6];
  while (1) {
    var6 = ((int *) var2)[10];
    var7 = ((int *) var2)[11];
    var8 = var5 + 0x00000001;
    ((int *) var2)[10] = (var6 + 0xFFFFFFFF);
    var4 = var4 + 0x00000001;
    ((int *) var2)[11] = (var7 + 0xFFFFFFFF);
    ((int *) var3)[6] = var8;
    var9 = ((unsigned char *) var5)[1];
    var10 = ((unsigned char *) var8)[1];
    var11 = 0x00000001;
    if ((((var9 << 0x00000008) | var10) & 0x0000FFFE) == 0x0000FFFA)
      break;
    if (((var4 < 0x000005A1)) != 0x00000000)
    {
      var5 = ((int *) var3)[6];
      continue;
    }
    else
    {
      var11 = 0x00000000;
    }
  }
  return var11;
}

/**
 * Subroutine at address 0x0000118C
 */
void sub_0118C (int arg1)
{
  sp = sp + 0xFFFFFFF0;
  ((int *) sp)[0] = ra;
  var1 = (((arg1 << 0x00000001) + arg1) << 0x00000006) + 0x00001680;
  var2 = ((int *) var1)[5];
  var3 = ((int *) var1)[4];
  if (var2 == var3)
  {
    var6 = ((int *) var1)[11];
    if (var6 > 0)
    {

    label9:
      sub_0007C (arg1);

    label11:
      ra = ((int *) sp)[0];
    }
    else
    {
      var7 = ((int *) var1)[1];
      if (var7 != 0x00000000)
      {
        ((int *) var1)[1] = (var7 - ((0x00000000 < var7)));
        sceMp3ResetPlayPosition (arg1);
        ra = ((int *) sp)[0];
      }
      else
      {
        ((int *) var1)[2] = 0x00000001;
        goto label11;
      }
    }
  }
  else
  goto label9;
  sp = sp + 0x00000010;
  return;
}

